package com.itheima.testlearn.test4;

import java.util.*;

public class Main{
    public static int[] num_leave=new int[100];
    public static int max_level=0;
    public static HashMap<Integer,ArrayList<Integer>> child = new HashMap<>();
    public static void main(String[] args){
        int N,M;
        int ID,K;
        Scanner sc = new Scanner(System.in);
        N=sc.nextInt();
        M=sc.nextInt();


        for(int i=0;i<M;i++){
            ID=sc.nextInt();
            K=sc.nextInt();
            for (int j = 0; j < K; j++) {
                child.computeIfAbsent(ID,k->new ArrayList<Integer>()).add(sc.nextInt());
            }

        }
        dfs(1,1);
        for (int i = 1; i < max_level+1; i++) {
            System.out.print(num_leave[i]+" ");
        }

    }

    public static void dfs(int curID,int curlevel){
        if(curlevel>max_level)max_level=curlevel;
        if(child.get(curID)!=null){
            for(int tmp:child.get(curID)) {
                dfs(tmp, curlevel + 1);
            }
        }
        else{
            num_leave[curlevel]++;
        }
    }

}


